package com.cloud.drore.eboss.supplier.mapper.provider;

import com.cloud.drore.eboss.supplier.entity.ProductValidateMethod;
import org.apache.commons.lang.StringUtils;

/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: <br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/2/5 16:46 <br>
 * @Author: <a href="575842778@qq.com">郑永涛</a>
 */
public class ProductValidateMethodProvider {

    public ProductValidateMethodProvider(){

    }

    private static String selectValidateMethodByParamSql = "select id,dic_code,name,product_id,product_type " +
            " from eboos_product_validate_method where is_deleted = '0' ";

    public String updateByParam(ProductValidateMethod productValidateMethod){
        String sql = "update eboos_product_validate_method set ";
        if(StringUtils.isNotBlank(productValidateMethod.getState()))
            sql += " state ='"+ productValidateMethod.getState()+"'" ;
        sql += " where id=" + productValidateMethod.getId();
        return sql;
    }

    public String selectValidateMethodByParam(ProductValidateMethod productValidateMethod){
        String sql = selectValidateMethodByParamSql;
        if(StringUtils.isNotBlank(productValidateMethod.getProductType()))
            sql += " and product_type = '" + productValidateMethod.getProductType() + "'";
        if(productValidateMethod.getProductId() != null)
            sql += " and product_id = " + productValidateMethod.getProductId() + "";
        if(StringUtils.isNotBlank(productValidateMethod.getState()))
            sql += " and state = '" + productValidateMethod.getState() + "'";
        return sql;
    }
}